package com.gitee.feizns.web.mvc.validate.annotation;

import com.gitee.feizns.web.dao.ar.AbstractModel;
import com.gitee.feizns.web.mvc.validate.UniqueValidator;

import javax.validation.Constraint;
import javax.validation.Payload;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
 * @author feizns
 * @since 2019/8/12
 */
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME)
@Constraint(validatedBy = UniqueValidator.class)
public @interface Unique {

    /**
     * 验证是否存在
     * @return
     */
    Class<? extends AbstractModel> value();

    /**
     * 验证的字段
     * @return
     */
    String field();

    /**
     * 是否必须
     * @return
     */
    boolean required() default true;

    /**
     * 错误码key
     * @return
     */
    String code() default "";

    /**
     * 消息
     * @return
     */
    String message() default "";

    /**
     * 分组
     * @return
     */
    Class<?>[] groups() default {};

    /**
     * 负载
     * @return
     */
    Class<? extends Payload>[] payload() default {};

}
